package com.example.mydianping.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.mydianping.pojo.Blog;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface BlogMapper extends BaseMapper<Blog> {
    @Update("update tb_blog set liked = liked + 1 where id = #{id}")
    Boolean likeAddOne(@Param("id") Long id);
    @Update("update tb_blog set liked = liked - 1 where id = #{id}")
    Boolean likeRemoveOne(@Param("id") Long id);
    //查询 id 下的所有博文
    @Select("select * from tb_blog where user_id = #{id}")
    List<Blog> getAllBlogs(@Param("id") Long id);
}
